const {createBiTree} = require('./createBitree');
 
const biTree = createBiTree(10);


/**
 * 
 * @param {biTree} root 
 * @description 层次遍历
 * @returns 
 */
function levelOrder(root) {

    if(root === null) {
        return;
    }
    const queue = [];

    queue.push(root);
    let temp = null;

    while(queue.length !== 0) {
        
        temp = queue.shift();
        
        console.log(temp.value);
        if(temp.left !== null) {
            queue.push(temp.left);
        }
        if(temp.right !== null) {

            queue.push(temp.right)
        }
        
    }
}


levelOrder(biTree);